﻿using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
using T4UtilityBelt.DataDesigns;
using T4UtilityBelt.Serializers;
using T4UtilityBelt.UxDesigns.Bindings;
using T4UtilityBelt.UxDesigns.Controls;
using T4UtilityBelt.UxDesigns.Screens.Renders;

namespace T4UtilityBelt.UxDesigns.Screens
{
    public class ContentEntityScreen<TView, TRenderer> : EntityScreen<TView, TRenderer>
        where TView : View<TView, TRenderer>
        where TRenderer : class, IViewRenderer<TView, TRenderer>
    {
        public ContentEntityScreen()
        {
            StandardConstructor();
        }

        public ContentEntityScreen(string entityName) : base(entityName)
        {
            StandardConstructor();
        }

        public ContentEntityScreen(string entityName, string screenName)
            : base(entityName, screenName)
        {
            StandardConstructor();
        }

        private void StandardConstructor()
        {
            //RenderHelpText = true;
            //Controls.DefaultPropertyDataContext = "Entry";
            //Controls.DefaultIsEnabledProperty = "CanCreate";

            _mainGrid = new GridControl();

            GridRow row = new GridRow();
            _mainGrid.Rows.Add(row);
            _titlePanel = new StackPanelControl();
            row.Controls.Add(_titlePanel);

            LabelControl title = new LabelControl { Text = this.Name };

            _titlePanel.Controls.Add(title);

            row = new GridRow();
            _mainGrid.Rows.Add(row);
            _content = new StackPanelControl();
            row.Controls.Add(_content);
            _content.DataContext = new Binding("Data");

            row = new GridRow();
            _mainGrid.Rows.Add(row);
            _buttonsPanel = new StackPanelControl();
            row.Controls.Add(_buttonsPanel);

            Controls.Add(_mainGrid);
        }

        private GridControl _mainGrid;
        public GridControl MainGrid
        {
            get { return _mainGrid; }
        }

        private StackPanelControl _titlePanel;
        public StackPanelControl TitlePanel
        {
            get { return _titlePanel; }
        }

        public ControlCollection TitleControls
        {
            get { return _titlePanel.Controls; }
        }

        private StackPanelControl _content;
        public StackPanelControl Content
        {
            get { return _content; }
        }

        public ControlCollection ContentControls
        {
            get { return _content.Controls; }
        }

        private StackPanelControl _buttonsPanel;
        public StackPanelControl ButtonPanel
        {
            get { return _buttonsPanel; }
        }

        public ControlCollection ButtonControls
        {
            get { return _buttonsPanel.Controls; }
        }
    }
}